*---------------------------------------------------------------*
*****************************************************************
* * REPLICATION MATERIAL FOR DATASET GENERATION FROM MASTER DATA FILE
*****************************************************************
*---------------------------------------------------------------*

**************************************
*generated: 2025-11  

*by Lukas Rudolph
*
*modified: --
*
*Data used: yougov_master.dta
*Data output generated: us_ukraine_replication.dta
*Tables generated: --
*Figutes generated: --
**************************************

*---------------------------------------------------------------*
*****************************************************************
* * Prepare Stata
*****************************************************************
*---------------------------------------------------------------*

version 16

********************************************************
*path
********************************************************
*working directory
cd "" // set working directory to folder where you upload the replication files

********************************************************
*load data
********************************************************

use yougov_master.dta, replace


********************************************************
*DATA WORK 
********************************************************

*****************
*ties
*****************
forvalues x = 1/9 {
forvalues y = 1/4 {
gen tie`x'task`y' = q2_attr`x'_concept1_task`y' == q2_attr`x'_concept2_task`y'  
}
}

********************************************************
*reshape conjoint
********************************************************
gen id = _n

reshape long q2_attr1_concept@_task1 q2_attr1_concept@_task2 q2_attr1_concept@_task3 q2_attr1_concept@_task4 ///
q2_attr2_concept@_task1 q2_attr2_concept@_task2 q2_attr2_concept@_task3 q2_attr2_concept@_task4  ///
q2_attr3_concept@_task1 q2_attr3_concept@_task2 q2_attr3_concept@_task3 q2_attr3_concept@_task4  ///
q2_attr4_concept@_task1 q2_attr4_concept@_task2 q2_attr4_concept@_task3 q2_attr4_concept@_task4  ///
q2_attr5_concept@_task1 q2_attr5_concept@_task2 q2_attr5_concept@_task3 q2_attr5_concept@_task4  ///
q2_attr6_concept@_task1 q2_attr6_concept@_task2 q2_attr6_concept@_task3 q2_attr6_concept@_task4  ///
q2_attr7_concept@_task1 q2_attr7_concept@_task2 q2_attr7_concept@_task3 q2_attr7_concept@_task4  ///
q2_attr8_concept@_task1 q2_attr8_concept@_task2 q2_attr8_concept@_task3 q2_attr8_concept@_task4  ///
q2_attr9_concept@_task1 q2_attr9_concept@_task2 q2_attr9_concept@_task3 q2_attr9_concept@_task4  ///
Q12B1_@ Q12B2_@ Q12B3_@ Q12B4_@ ///
 , i(id) j(concept)

reshape long q2_attr1_concept_task@ ///
q2_attr2_concept_task@  ///
q2_attr3_concept_task@  ///
q2_attr4_concept_task@  ///
q2_attr5_concept_task@  ///
q2_attr6_concept_task@  ///
q2_attr7_concept_task@  ///
q2_attr8_concept_task@  ///
q2_attr9_concept_task@  ///
Q12A@  Q12B@ Q12B@_ tie1task@ tie2task@ tie3task@ tie4task@ tie5task@ tie6task@ tie7task@ tie8task@ tie9task@ ///
 , i(id concept) j(task)

**** combined economic aid and military aid attribute expression for WTP 
gen econ = (q2_attr6_concept_task + q2_attr5_concept_task) - 1
tab econ 
 


********************************************************
*conjoint labels
********************************************************
label variable q2_attr1_concept_task "Number of Ukrainian soldiers killed?"
tab q2_attr1_concept_task 
d q2_attr1_concept_task
label define attr1 1 "12,500" 2 "25,000" 3 "50,000", replace
label values q2_attr1_concept_task attr1
tab q2_attr1_concept_task 

label variable q2_attr2_concept_task "Number of Russian soldiers killed?"
tab q2_attr2_concept_task 
label define attr2 1 "25,000" 2 "50,000" 3 "100,000", replace
label values q2_attr2_concept_task attr2 
tab q2_attr2_concept_task 

label variable q2_attr3_concept_task "Number of Ukrainian civilians killed?"
tab q2_attr3_concept_task 
d q2_attr3_concept_task
label define attr3 1 "4,000" 2 "8,000" 3 "16,000", replace
label values q2_attr3_concept_task attr3 
tab q2_attr3_concept_task 

label variable q2_attr4_concept_task "Value of destroyed infrastructure in Ukraine?"
tab q2_attr4_concept_task 
d q2_attr4_concept_task
label define attr4 1 "$50B" 2 "$100B" 3 "$200B", replace
label values q2_attr4_concept_task attr4 
tab q2_attr4_concept_task 

label variable q2_attr5_concept_task "[Country] contribution to military aid to Ukraine?"
tab q2_attr5_concept_task 
d q2_attr5_concept_task
label define attr5 1 "0.1% of GDP" ///
           2 "0.2% of GDP" ///
           3 "0.3% of GDP", replace

label values q2_attr5_concept_task attr5
tab q2_attr5_concept_task 

label variable q2_attr6_concept_task "[Country] contribution to economic aid to Ukraine?"
tab q2_attr6_concept_task 
d q2_attr6_concept_task
label define attr6 1 "0.1% of GDP" ///
           2 "0.2% of GDP" ///
           3 "0.3% of GDP", replace
label values q2_attr6_concept_task attr6
tab q2_attr6_concept_task 

label variable q2_attr7_concept_task "Risk of a Russian nuclear strike on Ukraine?"
tab q2_attr7_concept_task 
d q2_attr7_concept_task
label define attr7 1 "Not present (0%)" 2 "Low (5%)" 3 "Moderate (10%)", replace
label values q2_attr7_concept_task attr7
tab q2_attr7_concept_task 

label variable q2_attr8_concept_task "Territorial cessions of Ukraine to Russia?"
tab q2_attr8_concept_task 
d q2_attr8_concept_task
label define attr8 1 "None" ///
2 "Crimea (4%)" ///
3 "2014 LoC (8%)" ///
4 "2023 LoC (16%)", replace
label values q2_attr8_concept_task attr8
tab q2_attr8_concept_task 

label variable q2_attr9_concept_task "How much political self-determination of Ukraine?"
tab q2_attr9_concept_task 
d q2_attr9_concept_task
label define attr9 1 "Full" ///
2 "No EU/NATO" ///
3 "Russian influence", replace
label values q2_attr9_concept_task attr9
tab q2_attr9_concept_task 

********************************************************
*central IVs and DVs
********************************************************

*partisanship indicator
recode presvote20post (1=1) (2=2) (else = 3), gen(joedonnot)
label variable joedonnot "2020 pres. vote"
label define joedonnot 1 "Democrat" 2 "Republican" 3 "Non-voter"
label values joedonnot joedonnot

*strong Republican indicator
tab  pol_spect  if joe == 2 
recode pol_spect (0/7 = 1) (8/10 = 2), gen(strongright)
label variable strongright "Republican leaning"
label define strongright 1 "Moderate Republican" 2 "Strong Republican"
label values strongright strongright

**rating scale 
replace Q12B_ = (8 - Q12B_) if scale_Q8_Q12_Q13 == 2

*choice outcome
gen choice = 0  if concept != Q12A
replace choice = 1 if concept == Q12A 

** cooccurrence
sort id task concept 
foreach x in 1 2 3 4 5 6 7 8 9 {
gen cooccurence_attr`x' = 1 if (q2_attr`x'_concept_task == q2_attr`x'_concept_task[_n+1] & concept == 1) 
replace cooccurence_attr`x' = 1 if cooccurence_attr`x'[_n-1] == 1 & concept == 2
}

********************************************************
*non-voters partisanship
********************************************************
recode pid3 (1 = 1 "Democrat") (2 = 2 "Republican") (3 4 5 = 0 "Undecided"), gen(partyid)
gen demrep = joedonnot if joedonnot <= 2
replace demrep = 1 if Q4_2_US == 1 & demrep == .
replace demrep = 2 if Q4_2_US == 2 & demrep == .
tab Q4_2_US_open if demrep == .
replace demrep = 2 if demrep == . & (Q4_2_US_open == "Trump" | Q4_2_US_open == "trump" | Q4_2_US_open == "None of them, I can support Trump and Kennedy Jr I don't care what party they are as long as they go against the elites.")
replace demrep = 1 if pid3 == 1 & demrep == . 
replace demrep = 2 if pid3 == 2 & demrep == . 

corr demrep joedonnot if joedonnot <= 2
tab demrep joedonnot , miss
label define demrep 1  "Democrat" 2 "Republican", replace
label variable demrep "Vote intention"


********************************************************
*Balance test
********************************************************
recode gender (2=0), gen(male)
tab vRegionGrouped , gen(region)
recode education (1/5=1 "up to A-levels") (6/7 = 2 "post-secondary/vocational") (8/10 = 3 "BA/MA/PhD"), gen(edu3cat)
label variable edu3cat "Education"
tab edu3cat, gen(edu_cat)
recode employ (1/2 = 1 "employed") (3/4 = 2 "unemployed") (5 = 3 "retired") (6/9 = 4 "other"), gen(employed)
label variable employed "Employment"
tab employed, gen(employment)
recode profile_household_size (9/10 = .), gen(hh_size)
recode profile_gross_household (98 99 = .), gen(hh_income)
recode lmu_polInterest (5 = .), gen(pol_int)
recode religpew (1/4 = 1 "Christian") (5 = 2 "Jewish") (6 = 3 "Muslim") (7 8 12 = 4 "Other") (9 10 11 = 5 "None"), gen(rel)
label variable rel "Religion"
tab rel, gen(religion)
gen white = pastvote_by_race == "white, Biden" | pastvote_by_race == "white, DNV" | pastvote_by_race == "white, Other" | pastvote_by_race == "white, Trump"
label variable age "Age"
label variable region "Region"
label variable hh_size "HH size"
label variable hh_income "HH income"
label variable pol_int "Political interest"
label variable white "White"


********************************************************
*vignette analysis
********************************************************
gen vign = Vignette_show
label define vign 1 "air defence" 2 "air + tanks" 3 "air + tanks + jets" 4 "US soldiers" 5 "double econ. aid" 6 "max. sanctions", replace
label values vign vign

replace Q13n_1_1  = 8-Q13n_1_1 if conjoint_pipe2_up == "support"
recode Q13n_1_1 (-969 =.a) (977=.b)

label variable Q13n_1_1 "Support (1-7)"
label variable q13_2_2 "higher Ukr winning chance"
label variable q13_2_3 "higher WW3 risk"
label variable q13_2_6 "quicker war ending"
label variable q13_2_1 "more Ukr suffering/destruction"
label variable q13_2_4 "more refugees"
label variable q13_2_5	"domestic economic disadvantages"

********************************************************
*vignette subset
********************************************************
gen short = (task == 1 & concept == 1)


********************************************************
*task number indicator
********************************************************
gen task_no = .
replace task_no = UKR_ROUND2_task1 if task == 1
replace task_no = UKR_ROUND2_task2 if task == 2
replace task_no = UKR_ROUND2_task3 if task == 3
replace task_no = UKR_ROUND2_task4 if task == 4


********************************************************
* SAVE RECODED AND RESHAPED DATASET
********************************************************
save "us_ukraine_replication.dta", replace
